<extend name="Layout/application"/>

<block name="content">
   <section class="content-header">
      <h1>
         客资追踪
         <small>Tract index</small>
      </h1>
      <ol class="breadcrumb">
         <li><a href="#"><i class="fa fa-dashboard"></i> Tract</a></li>
         <li class="active">Index</li>
      </ol>
   </section>

   <section class="content">

      <include file="Layout/_flash"/>

      <div class="row">
         <div class="col-md-12">
            <div class="box">
               <div class="box-header">
                  <div class="col-md-5">
                     <a href="javascript:;" class="btn btn-primary btn-refresh" title="刷新"><i
                           class="fa fa-refresh"></i></a>
                     <a href="javascript:;" class="btn btn-danger btn-del delete_all" title="删除"><i
                           class="fa fa-trash"></i> 删除</a>
                     <a href="/admin/tracks/export_track" class="btn btn-primary btn-add" title="导出"><i
                           class="fa fa-sign-in"></i>
                        导出</a>
                  </div>

                  <!--搜索-->
                  <form action="" method="get">
                     <!--日期选择-->
                     <div class="col-md-4">
                        <div class="input-group input-group-sm" style="width: 280px;margin-top: 10px;">
                           <div class="input-group-btn">
                              <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                 <span class="field">{{$fieldDate|default='进店时间'}}</span>
                                 <i class="fa fa-caret-down"></i></button>
                              <input type="hidden" class="search_field" name="search_field"
                                     value="come_date">
                              <ul class="dropdown-menu search-ul">
                                 <li><a href="javascript:;" data-field="first_time">追踪时间</a></li>
                                 <li><a href="javascript:;" data-field="second_time">再次追踪</a></li>
                                 <li><a href="javascript:;" data-field="in_date">预计进店</a></li>
                                 <li><a href="javascript:;" data-field="come_date">进店时间</a></li>
                                 <li><a href="javascript:;" data-field="again_date">再次进店</a></li>
                              </ul>
                           </div>
                           <input type="text" name="date" value="{{$Request.param.date}}"
                                  class="form-control date">
                           <div class="input-group-btn">
                              <button type="submit" class="btn btn-default"><i class="fa fa-search"></i>
                              </button>
                           </div>
                        </div>
                     </div>
                  </form>

                  <form action="" method="get">
                     <!--输入框搜索-->
                     <div class="col-md-3">
                        <div class="input-group input-group-sm" style="width:280px;margin-top: 10px;">
                           <div class="input-group-btn">
                              <button type="button" class="btn btn-default dropdown-toggle search-drop-btn"
                                      data-toggle="dropdown" aria-expanded="false">
                                 <span class="field">{{$fieldName|default='客资ID'}}</span>
                                 <i class="fa fa-caret-down"></i>
                              </button>
                              <input type="hidden" class="search_field" name="search_field"
                                     value="customer_id">
                              <ul class="dropdown-menu search-ul">
                                 <li><a href="javascript:void(0)" data-field="customer_id">客资ID</a></li>
                                 <li><a href="javascript:void(0)" data-field="wang">网销</a></li>
                                 <li><a href="javascript:void(0)" data-field="menshi">门市</a></li>
                                 <li><a href="javascript:void(0)" data-field="fuwu">客服顾问</a></li>
                                 <li><a href="javascript:void(0)" data-field="lifu">礼服师</a></li>
                                 <li><a href="javascript:void(0)" data-field="huazhuang">化妆师</a></li>
                                 <li><a href="javascript:void(0)" data-field="lifu1">礼服师1</a></li>
                                 <li><a href="javascript:void(0)" data-field="huazhuang1">化妆师1</a></li>
                              </ul>
                           </div>
                           <input type="text" name="title" class="form-control pull-right"
                                  value="{{$Request.param.title}}" placeholder=""/>
                           <div class="input-group-btn">
                              <button type="submit" class="btn btn-default"><i class="fa fa-search"></i>
                              </button>
                           </div>
                        </div>
                     </div>
                  </form>

               </div>

               <!-- /.box-header -->
               <div class="box-body">
                  <table id="example2" class="table table-bordered table-hover">
                     <thead>
                     <tr>
                        <th>
                           <input type="checkbox" class="check_all">
                        </th>
                        <th>客资ID <a href="" class="fa fa-sort"></a></th>
                        <th>网销</th>
                        <th>追踪时间</th>
                        <th>详情</th>
                        <th>再次追踪</th>
                        <th>详情</th>
                        <th>备注</th>
                        <th>紧急</th>
                        <th>电话</th>
                        <th>预计进店日期</th>
                        <th>门市</th>
                        <th>进店
                           <div class="btn-group">
                              <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                                 <span class="caret"></span>
                              </button>
                              <ul class="dropdown-menu">
                                 <li><a href="">全部</a></li>
                                 <volist name="isComes" id="isCome">
                                    <li><a href="/admin/tracks/index?is_come={{$key}}">{{$isCome}}</a></li>
                                 </volist>
                              </ul>
                           </div>
                        </th>
                        <th>客服顾问</th>
                        <th>
                           <div class="btn-group">
                              <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                                 店铺<span class="caret"></span>
                              </button>
                              <ul class="dropdown-menu">
                                 <volist name="dians" id="dian">
                                    <li><a href="/admin/tracks/index?dian={{$dian}}">{{$dian}}</a></li>
                                 </volist>
                              </ul>
                           </div>
                        </th>
                        <th>进店时间</th>
                        <th>礼服师</th>
                        <th>化妆师</th>
                        <th>备注</th>
                        <th>再次进店</th>
                        <th>礼服师1</th>
                        <th>化妆师1</th>
                        <th>再次备注</th>
                     </tr>
                     </thead>
                     <tbody>

                     <volist name="tracks" id="track">

                        <tr data-id="{{$track.id}}">
                           <td>
                              <input type="checkbox" class="checked_id" name="check_id[]" value="{{$track.id}}">
                           </td>
                           <td>
                              <button type="button" data-toggle="modal" class="log" data-target="#log" title="日志"
                                      data-id="{{$track.customer.id}}">
                                 {{$track.customer.id}}
                              </button>
                           </td>
                           <!--网销-->
                           <td>{{$track.customer.wang}}</td>
                           <!--一次追踪时间-->
                           <td>
                              <input type="text" class="time first_time" data-id="{{$track.id}}" name="first_time"
                                     title="{{$track.first_time}}" value="{{$track.first_time}}">
                           </td>
                           <!--一次追踪详情-->
                           <td>
                              <button data-toggle="modal" data-target="#first_detail" class="beizhu"
                                      title="一次追踪详情" data-value="{{$track.first_detail}}">
                                 <if $track.first_detail>
                                    <i class="fa fa-eye"></i>
                                    <else/>
                                    <i class="fa fa-eye-slash"></i>
                                 </if>
                              </button>
                           </td>
                           <!--二次追踪时间-->
                           <td>
                              <input type="text" class="time second_time" data-id="{{$track.id}}" name="second_time"
                                     title="{{$track.second_time}}" value="{{$track.second_time}}">
                           </td>
                           <!--二次追踪详情-->
                           <td>
                              <button data-toggle="modal" data-target="#second_detail" class="beizhu"
                                      title="二次追踪详情" data-value="{{$track.second_detail}}">
                                 <if $track.second_detail>
                                    <i class="fa fa-eye"></i>
                                    <else/>
                                    <i class="fa fa-eye-slash"></i>
                                 </if>
                              </button>
                           </td>
                           <!--追踪备注-->
                           <td>
                              <button data-toggle="modal" data-target="#detail" class="beizhu" title="追踪备注"
                                      data-value="{{$track.detail}}">
                                 <if $track.detail>
                                    <i class="fa fa-eye"></i>
                                    <else/>
                                    <i class="fa fa-eye-slash"></i>
                                 </if>
                              </button>
                           </td>
                           <!--是否紧急客资-->
                           <td>
                              {{:is_something($track.customer,'is_urgent')}}
                           </td>
                           <!--是否电话客资-->
                           <td>
                              {{:is_something($track.customer,'is_phone')}}
                           </td>
                           <!--预计进店日期-->
                           <td>
                              <if condition="date('Y-m-d',strtotime($track.in_date)) == date('Y-m-d')">
                                 <input type="text" class="time in_date" data-id="{{$track.id}}" name="in_date"
                                        title="{{$track.in_date}}" value="{{$track.in_date}}"
                                        style="background:#ffaf0f;">
                                 <else/>
                                 <input type="text" class="time in_date" data-id="{{$track.id}}" name="in_date"
                                        title="{{$track.in_date}}" value="{{$track.in_date}}">
                              </if>
                           </td>
                           <!--门市-->
                           <td>
                              <div class="btn-group">
                                 <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                                    {{$track.menshi|default='未选择'}}<span class="caret"></span>
                                 </button>
                                 <ul class="dropdown-menu">
                                    <volist name="lifus" id="lifu">
                                       <li><a href="javascript:;" class="update" data-name="menshi"
                                              data-value="{{$lifu}}">{{$lifu}}</a></li>
                                    </volist>
                                 </ul>
                              </div>
                           </td>
                           <!--是否进店-->
                           <td>
                              {{:is_something($track,'is_come')}}
                           </td>
                           <!--客服顾问-->
                           <td>
                              <div class="btn-group">
                                 <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                                    {{$track.fuwu|default='未选择'}}<span class="caret"></span>
                                 </button>
                                 <ul class="dropdown-menu">
                                    <volist name="huazhuangs" id="huazhuang">
                                       <li><a href="javascript:;" class="update" data-name="fuwu"
                                              data-value="{{$huazhuang}}">{{$huazhuang}}</a></li>
                                    </volist>
                                 </ul>
                              </div>
                           </td>
                           <!--店铺-->
                           <td>{{$track.customer.dian}}</td>
                           <!--进店时间-->
                           <td>
                              <input type="text" class="time come_date" data-id="{{$track.id}}" name="come_date"
                                     title="{{$track.come_date}}" value="{{$track.come_date}}">
                           </td>
                           <!--礼服师1-->
                           <td>
                              <div class="btn-group">
                                 <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                                    {{$track.lifu|default='未选择'}}<span class="caret"></span>
                                 </button>
                                 <ul class="dropdown-menu">
                                    <volist name="lifus" id="lifu">
                                       <li><a href="javascript:;" class="update" data-name="lifu"
                                              data-value="{{$lifu}}">{{$lifu}}</a></li>
                                    </volist>
                                 </ul>
                              </div>
                           </td>
                           <!--化妆师1-->
                           <td>
                              <div class="btn-group">
                                 <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                                    {{$track.huazhuang|default='未选择'}}<span class="caret"></span>
                                 </button>
                                 <ul class="dropdown-menu">
                                    <volist name="huazhuangs" id="huazhuang">
                                       <li><a href="javascript:;" class="update" data-name="huazhuang"
                                              data-value="{{$huazhuang}}">{{$huazhuang}}</a></li>
                                    </volist>
                                 </ul>
                              </div>
                           </td>
                           <!--一次备注-->
                           <td>
                              <button data-toggle="modal" data-target="#beizhu1" class="beizhu" title="一次进店备注"
                                      data-value="{{$track.first_mark}}">
                                 <if $track.first_mark>
                                    <i class="fa fa-eye"></i>
                                    <else/>
                                    <i class="fa fa-eye-slash"></i>
                                 </if>
                              </button>
                           </td>
                           <!--再次进店时间-->
                           <td>
                              <input type="text" class="time again_date" data-id="{{$track.id}}" name="again_date"
                                     title="{{$track.again_date}}" value="{{$track.again_date}}">
                           </td>
                           <!--礼服师2-->
                           <td>
                              <div class="btn-group">
                                 <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                                    {{$track.lifu1|default='未选择'}}<span class="caret"></span>
                                 </button>
                                 <ul class="dropdown-menu">
                                    <volist name="lifus" id="lifu">
                                       <li><a href="javascript:;" class="update" data-name="lifu1"
                                              data-value="{{$lifu}}">{{$lifu}}</a></li>
                                    </volist>
                                 </ul>
                              </div>
                           </td>
                           <!--化妆师2-->
                           <td>
                              <div class="btn-group">
                                 <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                                    {{$track.huazhuang1|default='未选择'}}<span class="caret"></span>
                                 </button>
                                 <ul class="dropdown-menu">
                                    <volist name="huazhuangs" id="huazhuang">
                                       <li><a href="javascript:;" class="update" data-name="huazhuang1"
                                              data-value="{{$huazhuang}}">{{$huazhuang}}</a></li>
                                    </volist>
                                 </ul>
                              </div>
                           </td>
                           <!--再次备注-->
                           <td>
                              <button data-toggle="modal" data-target="#beizhu2" class="beizhu" title="二次进店备注"
                                      data-value="{{$track.second_mark}}">
                                 <if $track.second_mark>
                                    <i class="fa fa-eye"></i>
                                    <else/>
                                    <i class="fa fa-eye-slash"></i>
                                 </if>
                              </button>
                           </td>
                        </tr>
                     </volist>


                     </tbody>
                  </table>

                  <div class="box-footer">
                     共 {{$tracks->total()}} 条数据
                     <div class="page">
                        {{$tracks->render()|raw}}
                     </div>
                  </div>
               </div>
               <!-- /.box-body -->
            </div>
            <!-- /.box -->
         </div>
         <!-- /.col -->
      </div>
      <!-- /.row -->
   </section>

   <!--客资追踪日志-->
   <div class="modal fade" id="log">
      <div class="modal-dialog">
         <div class="modal-content">
            <div class="modal-header">
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span></button>
               <h4 class="modal-title">日志</h4>
            </div>
            <div class="modal-body" id="showLog">

            </div>
            <div class="modal-footer">
               <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
            </div>
         </div>
      </div>
   </div>

   <!--一次追踪详情-->
   <div class="modal fade" id="first_detail">
      <div class="modal-dialog">
         <div class="modal-content">
            <div class="modal-header">
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span></button>
               <h4 class="modal-title">一次追踪详情</h4>
            </div>
            <div class="modal-body">
               <input type="hidden" id="detail1">
               <textarea name="first_detail" id="first_detail1" cols="15" rows="5" class="form-control"
                         placeholder="请输入一次追踪详情"></textarea>
            </div>
            <div class="modal-footer">
               <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
               <button type="button" class="btn btn-primary detailSubmit1">提交</button>
            </div>
         </div>
      </div>
   </div>

   <!--二次追踪详情-->
   <div class="modal fade" id="second_detail">
      <div class="modal-dialog">
         <div class="modal-content">
            <div class="modal-header">
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span></button>
               <h4 class="modal-title">二次追踪详情</h4>
            </div>
            <div class="modal-body">
               <input type="hidden" id="detail2">
               <textarea name="second_detail" id="second_detail2" cols="15" rows="5" class="form-control"
                         placeholder="请输入二次追踪详情"></textarea>
            </div>
            <div class="modal-footer">
               <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
               <button type="button" class="btn btn-primary detailSubmit2">提交</button>
            </div>
         </div>
      </div>
   </div>

   <!--追踪详情备注-->
   <div class="modal fade" id="detail">
      <div class="modal-dialog">
         <div class="modal-content">
            <div class="modal-header">
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span></button>
               <h4 class="modal-title">追踪详情备注</h4>
            </div>
            <div class="modal-body">
               <input type="hidden" id="detail3">
               <textarea name="detail" id="last_detail" cols="15" rows="5" class="form-control"
                         placeholder="请输入追踪详情"></textarea>
            </div>
            <div class="modal-footer">
               <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
               <button type="button" class="btn btn-primary detailSubmit">提交</button>
            </div>
         </div>
      </div>
   </div>

   <!--一次备注查看-->
   <div class="modal fade" id="beizhu1">
      <div class="modal-dialog">
         <div class="modal-content">
            <div class="modal-header">
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span></button>
               <h4 class="modal-title">一次进店备注</h4>
            </div>
            <div class="modal-body">
               <input type="hidden" id="mark1">
               <textarea name="first_mark" id="first_mark" cols="15" rows="5" class="form-control"
                         placeholder="请输入一次进店备注"></textarea>
            </div>
            <div class="modal-footer">
               <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
               <button type="button" class="btn btn-primary submit1">提交</button>
            </div>
         </div>
      </div>
   </div>

   <!--二次备注查看-->
   <div class="modal fade" id="beizhu2">
      <div class="modal-dialog">
         <div class="modal-content">
            <div class="modal-header">
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span></button>
               <h4 class="modal-title">二次进店备注</h4>
            </div>
            <div class="modal-body">
               <input type="hidden" id="mark2">
               <textarea name="second_mark" id="second_mark" cols="15" rows="5" class="form-control"
                         placeholder="请输入二次进店备注"></textarea>
            </div>
            <div class="modal-footer">
               <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
               <button type="button" class="btn btn-primary submit2">提交</button>
            </div>
         </div>
      </div>
   </div>

</block>

<block name="js">
   <script>
      $(function () {
         //日期范围选择
         laydate.render({
            elem: '.date',
            range: '~',
         });
         // 搜索框
         $('body').on("click", '.search-ul li a', function (event) {
            var _this = $(this);
            var _field = _this.data('field');
            var _html = _this.html();
            var _box = _this.closest('.input-group-btn');
            _box.find('.search_field').val(_field);
            _box.next('input').attr('placeholder', _html);
            _box.find('.field').html(_html);
         });

         //刷新
         $('.btn-refresh').click(function () {
            window.location.reload();
         });

         //上面选中，下面也选中
         $('.check_all').click(function () {
            var checked = $(this).prop('checked');
            $('.checked_id').prop('checked', checked).parents('tr').toggleClass('selected');
         });
         //点击切换背景色
         $('.checked_id').click(function () {
            $(this).parents('tr').toggleClass('selected');
         });

         //多选删除
         $('.delete_all').click(function () {
            var check_length = $('.checked_id:checked').length;
            if (check_length == 0) {
               layer.msg('请你至少选中一条', {icon: 2, offset: 't'});
               return false;
            }

            layer.confirm('确认删除选中的 ' + check_length + ' 条吗?',
               {icon: 3, title: '提示', offset: 't'},
               function (index) {
                  layer.close(index);

                  $.ajax({
                     type: 'DELETE',
                     url: '/admin/tracks/delete_all',
                     data: $('.checked_id:checked').serialize(),
                     success: function (data) {
                        //判断有没有权限
                        if (data && data.status == 0) {
                           layer.msg(data.msg, {
                              icon: 5,
                              time: 2000, //2秒关闭（如果不配置，默认是3秒）
                              offset: 't'
                           });
                           return false;
                        } else {
                           $('.checked_id:checked').parents('tr').fadeOut(400);
                        }
                     }
                  });
               });
            return false;
         });

         //查看日志
         $('.log').click(function () {
            var log_id = $(this).data('id');
            $.ajax({
               type: 'POST',
               data: {log_id: log_id},
               url: "{{:url('tracks/showLog')}}",
               success: function (data) {
                  //判断有没有权限
                  if (data && data.status == 0) {
                     layer.msg(data.msg, {
                        icon: 5,
                        time: 2000, //2秒关闭（如果不配置，默认是3秒）
                        offset: 't'
                     });
                     return false;
                  } else {
                     var str = '';
                     $.each(data, function (i, item) {
                        str += '<p>' + '[' + item.create_at + ']' + item.log + '</p>';
                     });
                     $('#showLog').html(str);
                     return false;
                  }
               }
            });
         });

         //改变属性----是否进店
         $('.change_attr').click(function () {
            var id = $(this).parents('tr').data('id');
            var attr = $(this).data('attr');
            var _this = $(this);

            layer.confirm('确认改变吗?',
               {icon: 3, title: '提示', offset: 't'},
               function (index) {
                  layer.close(index);

                  $.ajax({
                     type: 'PATCH',
                     url: '/admin/tracks/change',
                     data: {id: id, attr: attr},
                     success: function (data) {
                        console.log(data);
                        //判断有没有权限
                        if (data && data.status == 0) {
                           layer.msg(data.msg, {
                              icon: 5,
                              time: 2000, //2秒关闭（如果不配置，默认是3秒）
                              offset: 't'
                           });
                           return false;
                        } else {
                           _this.toggleClass('fa fa-check-circle fa fa-times-circle');
                        }
                     }
                  })
               });
            return false;
         });

         //编辑信息
         $('.update').click(function () {
            var info = {
               id: $(this).parents('tr').data('id'),
               val: $(this).data('value'),
               name: $(this).data('name'),
            };
            edit_track(info);
            return false;
         });

         //一次追踪时间
         lay('.first_time').each(function () {
            laydate.render({
               elem: this, //指定元素
               type: 'datetime',
               done: function (value) {
                  // console.log(value); //得到日期生成的值，如：2017-08-18
                  var info = {
                     id: this.elem.attr('data-id'),
                     name: this.elem.attr('name'),
                     val: value
                  };
                  edit_track(info);
                  return false;
               }
            });
         });

         //再次追踪时间
         lay('.second_time').each(function () {
            laydate.render({
               elem: this, //指定元素
               type: 'datetime',
               done: function (value) {
                  // console.log(value); //得到日期生成的值，如：2017-08-18
                  var info = {
                     id: this.elem.attr('data-id'),
                     name: this.elem.attr('name'),
                     val: value
                  };
                  edit_track(info);
                  return false;
               }
            });
         });

         //预计进店时间选择
         lay('.in_date').each(function () {
            laydate.render({
               elem: this, //指定元素
               type: 'datetime',
               done: function (value) {
                  // console.log(value); //得到日期生成的值，如：2017-08-18
                  var info = {
                     id: this.elem.attr('data-id'),
                     name: this.elem.attr('name'),
                     val: value
                  };
                  edit_track(info);
                  return false;
               }
            });
         });

         //进店时间选择
         lay('.come_date').each(function () {
            laydate.render({
               elem: this, //指定元素
               type: 'datetime',
               done: function (value) {
                  // console.log(value); //得到日期生成的值，如：2017-08-18
                  var info = {
                     id: this.elem.attr('data-id'),
                     name: this.elem.attr('name'),
                     val: value
                  };
                  edit_track(info);
                  return false;
               }
            });
         });


         //再次进店时间
         lay('.again_date').each(function () {
            laydate.render({
               elem: this, //指定元素
               type: 'datetime',
               done: function (value) {
                  // console.log(value); //得到日期生成的值，如：2017-08-18
                  var info = {
                     id: this.elem.attr('data-id'),
                     name: this.elem.attr('name'),
                     val: value
                  };
                  edit_track(info);
                  return false;
               }
            });
         });

         //更新数据的公共方法
         function edit_track(info) {
            layer.confirm('确认更新信息吗?',
               {icon: 3, title: '提示', offset: 't'},
               function (index) {
                  layer.close(index);

                  $.ajax({
                     url: "{{:url('tracks/edit_track')}}",
                     data: info,
                     type: 'POST',
                     success: function (data) {
                        //判断有没有权限
                        if (data && data.status == 0) {
                           layer.msg(data.msg, {
                              icon: 5,
                              time: 2000, //2秒关闭（如果不配置，默认是3秒）
                              offset: 't'
                           });
                           return false;
                        } else {
                           window.location.reload();
                        }
                     }
                  });
               }
            )
         }

         //备注
         $('.beizhu').click(function () {
            var info = {
               id: $(this).parents('tr').data('id'),
               val: $(this).data('value')
            };
            //一次追踪详情
            $('#detail1').val(info.id);
            $('#first_detail1').val(info.val);
            //二次追踪详情
            $('#detail2').val(info.id);
            $('#second_detail2').val(info.val);
            //追踪详情
            $('#detail3').val(info.id);
            $('#last_detail').val(info.val);
            //一次进店备注
            $('#mark1').val(info.id);
            $('#first_mark').val(info.val);
            //二次进店备注
            $('#mark2').val(info.id);
            $('#second_mark').val(info.val);
         });
         //一次追踪详情
         $('.detailSubmit1').click(function () {
            var info = {
               id: $('#detail1').val(),
               name: $('#first_detail1').attr('name'),
               val: $('#first_detail1').val()
            };
            edit_track(info);
            return false;
         });
         //二次追踪详情
         $('.detailSubmit2').click(function () {
            var info = {
               id: $('#detail2').val(),
               name: $('#second_detail2').attr('name'),
               val: $('#second_detail2').val()
            };
            edit_track(info);
            return false;
         });
         //追踪详情
         $('.detailSubmit').click(function () {
            var info = {
               id: $('#detail3').val(),
               name: $('#last_detail').attr('name'),
               val: $('#last_detail').val()
            };
            edit_track(info);
            return false;
         });
         //更新一次进店备注
         $('.submit1').click(function () {
            var info = {
               id: $('#mark1').val(),
               name: $('#first_mark').attr('name'),
               val: $('#first_mark').val()
            };
            edit_track(info);
            return false;
         });
         //更新二次进店备注
         $('.submit2').click(function () {
            var info = {
               id: $('#mark2').val(),
               name: $('#second_mark').attr('name'),
               val: $('#second_mark').val()
            };
            edit_track(info);
            return false;
         })
      });
   </script>

</block>



